import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

/*
 * UIResults.java
 * Author: Russell Sowell
 * Last Updated: 2/4/2014
 */
public class UIResults {

	private static JFrame myMainFrame;
	private static JPanel myMainPanel;
	private static JTextArea myResultsArea = new JTextArea(10, 20);
	private static JButton myCloseButton = new JButton("Close");
	
	public UIResults()
	{
		initializeFrame();
		initializeLayout();
		
		myCloseButton.addActionListener(new ListenClose());
	}
	
	private void initializeFrame()
	{
		myMainFrame = new JFrame();
		myMainPanel = new JPanel();
		
		myMainFrame.setSize(600, 400);
		myMainFrame.setTitle("Results");
		myMainFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		myMainFrame.setResizable(false);
		myMainFrame.setVisible(false);
		
		myMainFrame.add(myMainPanel);
	}
	
	private void initializeLayout()
	{
		myMainPanel.setLayout(new BorderLayout());
		
		myResultsArea.setEditable(false);
		JScrollPane scroll = new JScrollPane(myResultsArea);
		
		myMainPanel.add(new JLabel("Results", JLabel.CENTER), BorderLayout.NORTH);
		myMainPanel.add(scroll);
		myMainPanel.add(myCloseButton, BorderLayout.SOUTH);
	}
	
	private class ListenClose implements ActionListener {
		@Override
		public void actionPerformed(ActionEvent e) {
			myMainFrame.setVisible(false);
			
		}
		
	}
	
	public void updateResults(String results)
	{
		myMainFrame.setVisible(true);
		myResultsArea.setText(results);
	}
	
	public static void main(String[] args) {
		UIResults gui = new UIResults();

	}
}
